unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  arr : array [0..99] of TButton;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var i : integer;
begin
  for i := 0 to 99 do
  begin
    arr[i] := TButton.Create(Form1);
    arr[i].Parent := Form1;
    arr[i].Width := 50;
    arr[i].Height := 50;
    arr[i].Top := random(Form1.Height);
    arr[i].Left := random(Form1.Width);
    arr[i].OnClick := Button2Click;
  end;
end;

procedure TForm1.Button2Click(Sender: TObject);
var i : integer;
begin
  for i := 0 to 99 do
  begin
    if (Sender = arr[i]) then
    begin
      arr[i].Caption := 'Test';
    end;
  end;
end;

end.
